<template>
  <div>
    <div class="main">
      <el-avatar
        shape="square"
        style="margin: auto 0"
        :size="48"
        :src="squareUrl"
      />
      <div style="margin: auto 20px; font-size: 24px; color: #80a492" @click="toLogin">{{name === '' ? '登录' : name}}</div>
    </div>
    <ul v-infinite-scroll="load" class="infinite-list" style="overflow: auto">
      <li
        v-for="(item, index) in paths"
        :key="index"
        class="infinite-list-item"
        @click="toPath(item.path)"
      >
        {{ item.name }}<el-icon><ArrowRight /></el-icon>
      </li>
    </ul>
  </div>
</template>

<script>
export default {
  name: "",
  data() {
    return {
      name: "Fall",
      count: 0,
      squareUrl:
        "https://cube.elemecdn.com/9/c2/f0ee8a3c7c9638a54940382568c9dpng.png",
      paths: [
        {
          name: "修改密码",
          path: '/change'
        },
        {
          name: '挂号历史',
          path: '/RegisterDetail'
        }
      ],
    };
  },
  methods: {
    load() {
      this.count += 2;
    },

    toLogin() {
      // if (this.name === '') {
        this.$router.push({
          path: 'login'
        })
      // }
    },
    toPath(value) {
      this.$router.push({
          path: value
        })
    }
  },
  created() {
    this.name = this.$store.getters.getName
  }
};
</script>

<style scoped>
.main {
  width: calc(100vw - 20px);
  height: 100px;
  display: flex;
  padding: 20px 0 20px 20px;
  background-color: #d5ebe1;
}

.infinite-list {
  width: calc(100vw);
  height: 300px;
  padding: 0;
  margin: 0;
  list-style: none;
}
.infinite-list .infinite-list-item {
  display: flex;
  align-items: center;
  justify-content: center;
  height: 50px;
  background: rgba(213, 235, 225, 0.5);
  margin: 10px 0;
  padding: 0 10px;
  color: #80a492;
  justify-content: space-between;
}
.infinite-list .infinite-list-item + .list-item {
  margin-top: 10px;
}
</style>